package my.georings;

import java.util.List;

import my.georings.data.MyLocationsManager;
import my.georings.data.Settings;
import android.app.ActivityManager;
import android.app.Application;
import android.app.ActivityManager.RunningServiceInfo;
import android.content.ComponentName;



public class GeoPhoneRingsApp extends Application {

	private MyLocationsManager myLocationsManager;
	private Settings settings = new Settings();
	
	private boolean restart = false;
	private boolean serviceWasStarted = false;
	
	public void init(){
		myLocationsManager = new MyLocationsManager();
		settings = new Settings();
	}
	
	public MyLocationsManager getMyLocationsManager() {
		return myLocationsManager;
	}
	
	public void setMyLocationsManager(MyLocationsManager myLocationsManager) {
		this.myLocationsManager = myLocationsManager;
	}

	public Settings getSettings() {
		return settings;
	}
	
	public void setSettings(Settings settings) {
		this.settings = settings;
	}
	

	public boolean checkServiceRunning(){
		ActivityManager actvityManager = (ActivityManager) this.getSystemService( ACTIVITY_SERVICE );
        List<ActivityManager.RunningServiceInfo> list = actvityManager.getRunningServices(Integer.MAX_VALUE);
        
        ComponentName name = new ComponentName("my.georings", "my.georings.service.LocationChangeService");
        
        for(int i = 0; i < list.size(); ++i){
        	RunningServiceInfo info = ((ActivityManager.RunningServiceInfo)list.get(i));
        	if( info.service.toString().equals(name.toString())){
        		return true;
        	}
        }
        return false;
	}

	public boolean isRestart() {
		return restart;
	}

	public void setRestart(boolean restart) {
		this.restart = restart;
	}

	public boolean isServiceWasStarted() {
		return serviceWasStarted;
	}

	public void setServiceWasStarted(boolean serviceWasStarted) {
		this.serviceWasStarted = serviceWasStarted;
	}
	
	

}
